package org.acegisecurity.util.expressioninterpreter;

/**
 * Class representing the ( operator. The ( operator cannot be applied to an operand from the value {@link org.acegisecurity.util.expressioninterpreter.Stack} so
 * the apply method throws an IllegalStateException. This class is used by the ExpressionInterpreter to indicate
 * that a ( exists so that everything between the () must be threated as an expression.
 *
 * @author Jamie Craane
 * @author Ivo Woltring
 */
public class LeftParenthesisOperator implements Operator {
    public static final String LEFT_PARENTHESIS_OPERATOR = "(";

    /**
     * @throws IllegalStateException Note that the LeftParenthesisOperator cannot be applied to an operand
     *                               so this method throws an IllegalStateException
     * @see Operator#apply(String[], Stack)
     */
    public boolean apply(String[] roles, Stack valueStack) {
        throw new IllegalStateException();
    }

    /**
     * {@inheritDoc}
     */
    public String toString() {
        return LEFT_PARENTHESIS_OPERATOR;
    }

    /**
     * Return false because the LeftParenthesisOperator is not considerd an operator.
     */
    public boolean hasGreaterPrecedenceThan(Operator thisOp) {
        return false;
    }
}
